package com.hrt.day04.implicitdemo
import java.io.File
import scala.io.Source

/**
 * 隐式转换函数
 */
object Implicit2 {
    def main(args: Array[String]): Unit = {
        implicit def file2RichFile(file: File): RichFile = new RichFile(file)
        
        val content: String = new File("F:\\idea2019_workspace\\bigdata202006_projects" +
          "\\base-scala\\src\\main\\scala\\com\\hrt\\day04\\implicitdemo\\Implicit1.scala")
            .readContent
        println(content)
    }
}
class RichFile(file: File) {
    def readContent: String = {
        Source.fromFile(file, "utf-8").mkString
    }
}
/**
File 只是封装了文件的元数据., 文件内容必须通过IO
 */